package com.lazybones.base.engineer.controller.mail;

import com.lazybones.base.engineer.service.mail.IMailService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/mail/")
public class MailController {
    private final IMailService iMailService;

    public MailController(IMailService iMailService) {
        this.iMailService = iMailService;
    }

    @RequestMapping(value = "testSend",method = RequestMethod.GET)
    public String testSend(@RequestParam("to") String to ,@RequestParam("subject") String subject,@RequestParam("text") String text){
        iMailService.sendText(to,subject,text);
        return  "";
    }
    @RequestMapping(value = "testHtmlSend",method = RequestMethod.GET)
    public String testHtmlSend(@RequestParam("to") String to ,@RequestParam("subject") String subject,@RequestParam("text") String text){
        iMailService.sendHtml(to,subject,text);
        return "";
    }
    @RequestMapping(value = "testFileSend",method = RequestMethod.GET)
    public String testFileSend(@RequestParam("to") String to , @RequestParam("subject") String subject, @RequestParam("text") String text
    , @RequestParam("filePath") String filePath){
        iMailService.sendMimeMessages(to,subject,text,filePath);
        return "";
    }
}
